package com.five.calendar.alarmmanager.clock;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Vibrator;

import com.five.calendar.ApplicationHelper;
import com.five.calendar.utils.TimeUtils;

/**
 * Created by loongggdroid on 2016/3/21.
 */
public class LoongggAlarmReceiver extends BroadcastReceiver {
    private MediaPlayer mediaPlayer;
    private Vibrator vibrator;

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        String msg = intent.getStringExtra("msg");
        int flag = intent.getIntExtra("soundOrVibrator", 0);
        int repeat = intent.getIntExtra("repeat", 0);
        int id = intent.getIntExtra("id", 0);
        Intent clockIntent = new Intent(context, ClockAlarmActivity.class);
        clockIntent.putExtra("msg", msg);
        clockIntent.putExtra("flag", flag);
        clockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(clockIntent);
        if (repeat > 0){
            AlarmManagerUtil.setGoalAlarm(ApplicationHelper.getContext(), 0, System.currentTimeMillis() + TimeUtils.DAY, id, 0, msg, 2, repeat -1);
        }
    }


}
